package com.sun.lotter;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.KeyEvent;

import com.mobclick.android.MobclickAgent;
import com.sun.base.BaseTabActivity;
import com.sun.chart.ChartImageActivity;
import com.sun.lotter.local.record.LotterLocalRecordActivity;
import com.sun.lotter.luck.LuckLotterActivity;
import com.sun.opne.OpneLotteryInfo;
import com.tools.MyLog;
import com.tools.SysInterfacePhone;

public class DoubleLotterNewsActivity extends BaseTabActivity {
	
	@SuppressWarnings("deprecation")
	@Override
	public void init() {
		setTitle("双色球查询");
		SysInterfacePhone.invoker().setViewBackground(this, titleLayout, "titlebackground.png");
		getTabHost().addTab(getTabHost().newTabSpec("item1").setIndicator("选号器").setContent(new Intent(this, LuckLotterActivity.class)));
		getTabHost().addTab(getTabHost().newTabSpec("item2").setIndicator("开奖信息").setContent(new Intent(this, OpneLotteryInfo.class)));
		getTabHost().addTab(getTabHost().newTabSpec("item3").setIndicator("走势图").setContent(new Intent(this, ChartImageActivity.class)));
		getTabHost().addTab(getTabHost().newTabSpec("item4").setIndicator("更多").setContent(new Intent(this, LotterLocalRecordActivity.class)));
		MobclickAgent.setUpdateOnlyWifi(false);
		MobclickAgent.update(this);
	}
	
	@Override
	public void onClickBottom(int bottomIndex) {}
	
	/**/
	@Override
	public boolean onKeyDown(final int keyCode, final KeyEvent event) {
		MyLog.v(keyCode + ":" + KeyEvent.KEYCODE_BACK);
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			AlertDialog dialog = SysInterfacePhone.invoker().createDialog(this, "你确定要退出吗？");
			dialog.setButton("确定", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					DoubleLotterNewsActivity.super.onKeyDown(keyCode, event);
				}
			});
			dialog.setButton2("取消", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					
				}
			});
			dialog.show();
			return true;
		} else return super.onKeyDown(keyCode, event);		
	}
}